package com.tjsinfo.tjsoa.vote.bo;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;

import com.tjsinfo.tjsoa.Dao.IQbcDao;
import com.tjsinfo.tjsoa.vote.dao.ITVoteHeadDAO;
import com.tjsinfo.tjsoa.vote.vo.TVoteHead;

public class TVoteHeadBO implements ITVoteHeadBO {
	
	private IQbcDao qbcDao;	
	private ITVoteHeadDAO headDao;
	
	public IQbcDao getQbcDao() {
		return qbcDao;
	}
	public void setQbcDao(IQbcDao qbcDao) {
		this.qbcDao = qbcDao;
	}
	public ITVoteHeadDAO getHeadDao() {
		return headDao;
	}
	public void setHeadDao(ITVoteHeadDAO headDao) {
		this.headDao = headDao;
	}
	
	public void save(TVoteHead transientInstance) {
		// TODO Auto-generated method stub
		headDao.save(transientInstance);
	}
	public List<TVoteHead> selectAll(Integer first, Integer max,HttpServletRequest request) {
		// TODO Auto-generated method stub
		DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TVoteHead.class);
		//detachedCriteria.add(Restrictions.eq("userId", String.valueOf(ToolKit.getSessionUser(request).getUser_id())));
		List<Order> orderlist= new ArrayList<Order>();
		orderlist.add(Order.desc("yearTime"));
		return qbcDao.findPageByCriteria(detachedCriteria, orderlist, max, first).getItems();
	}
	public Integer selectTotal() {
		// TODO Auto-generated method stub
		DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TVoteHead.class);
		return  qbcDao.getQueryNumber(detachedCriteria, "id");
	}
	public TVoteHead findById(String id) {
		// TODO Auto-generated method stub
		return headDao.findById(id);
	}
	public void update(TVoteHead transientInstance) {
		// TODO Auto-generated method stub
		headDao.update(transientInstance);
	}
	public void delete(String id) {
		// TODO Auto-generated method stub
		headDao.delete(id);
	}

}
